using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;


using Newtonsoft.Json;

public class DataManager : Singleton<DataManager>
{
    public string DataPath;
    public Dictionary<int, ItemDefine> Items = null;



    public DataManager()
    {
        this.DataPath = "Assets/BuildResources/Config/";
        Debug.LogFormat("DataManager > DataManager()");
    }

    
    public void Load()
    {
        Manager.Resource.LoadConfig(DataPath + "ItemDefine.txt", (Object obj) =>
        {
            string json = obj.ToString();
            this.Items = JsonConvert.DeserializeObject<Dictionary<int, ItemDefine>>(json);
        });
        //string json = File.ReadAllText(this.DataPath + "ItemDefine.txt");
        //this.Items = JsonConvert.DeserializeObject<Dictionary<int, ItemDefine>>(json);
    }


    public IEnumerator LoadData()
    {
        string json = File.ReadAllText(this.DataPath + "ItemDefine.txt");
        this.Items = JsonConvert.DeserializeObject<Dictionary<int, ItemDefine>>(json);

        yield return null;
    }
}


